
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include "sans.h"
#include "garbagecollector.h"
#include "runtime.h"
#include "symboltable.h"

sdata bltn_read_char() {
  if(!feof(stdin)) {
    char c = getc(stdin);
    return SDCHAR(c);
  }
  else {
    return SDEOF();
  }
}

sdata bltn_unread_char(sdata ob) {
  if(ob.tag != tchar) {
    log_err("bltn_unread_char: ob not a character\n");
  }
  ungetc((char)ob.data.ivalue, stdin);
  return SDBOOL(0);
}

sdata bltn_exit(sdata ob) {
  if (ob.tag != tnumb) {
    log_err("runtime/exit: ob not a number\n");
  }
  
  exit(ob.data.ivalue);
  return(SDBOOL(0));
}
